package cn.edu.neu.studentmsg_java.service.impl;

import cn.edu.neu.studentmsg_java.dao.CourseDao;
import cn.edu.neu.studentmsg_java.dao.MCDao;
import cn.edu.neu.studentmsg_java.model.Course;
import cn.edu.neu.studentmsg_java.service.MCService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class MCServiceImpl implements MCService {
    @Autowired
    private MCDao mcDao;
    @Autowired
    private CourseDao courseDao;
    @Override
    public Course findCourseByCourseId(Integer course_id) {
        int category = courseDao.selectCategoryByCourseId(course_id);
        if (category == 1) {
            //如果为1证明是必修课，需要获取课程id，课程名称，课程类别，专业名称
            return mcDao.selectCourseByCourseId(course_id);
        } else if (category == 2) {
            //如果为2证明是选修课，需要获取课程id，课程名称，课程类别
            return courseDao.selectSCourseByCourseId(course_id);
        }
        return null;
    }
}
